import RouterHandle from "./RouterHandle";
/**
 全局通用工具类
*/
var Utils={
	RouterHandle:RouterHandle, 
	//初始化字体1rem的值，便于兼容各种设备
	initialFontSize: function() {
		(function(doc, win) {
			var docEl = doc.documentElement,
				resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
				recalc = function() {
					var clientWidth = docEl.clientWidth;
					if (!clientWidth) return;
					var size=20 * (clientWidth / 320) * 0.6826;
					window.rem=size;
					docEl.style.fontSize = size + 'px' ;
					document.body.style.fontSize = docEl.style.fontSize;
				};
			if (!doc.addEventListener) return;
			win.addEventListener(resizeEvt, recalc, false);
			doc.addEventListener('DOMContentLoaded', recalc, false);
		})(document, window);
	},
    //前往某个路由，参数为可选，如果需要调用原生的页面则需要添加参数params
    go:function(path,params){
    	RouterHandle.go(path,params);
    },
    //返回如果path为空，则使用hashhistory的back
    back:function(path,nonAnimate,animateName){ 
    	RouterHandle._back(path,nonAnimate,animateName);
    },
    showLoading:function(content){},
    hideLoading:function(){}
};
module.exports=Utils;